package com.bw.producer.controller;

import com.bw.producer.Vo.CartItemVo;
import com.bw.producer.Vo.CartRequest;
import com.bw.producer.Vo.CartVo;
import com.bw.producer.service.CartItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("cartItem")
@RestController
public class CartItemController {
    @Autowired
    private CartItemService cartItemService;

    /**
     * 添加购物车
     * @param cartRequest
     */
    @PostMapping("addCartItem")
    public void addCartItem(@RequestBody CartRequest cartRequest) {
        cartItemService.addCartItem(cartRequest);
    }

    /**
     * 删除购物车
     * @param skuIds
     */
    @DeleteMapping("deleteCartItem/{skuIds}")
    public void deleteCartItem(@PathVariable String skuIds) {
        cartItemService.deleteCartItem(skuIds);
    }

    /**
     * 购物车列表
     * @return
     */
    @GetMapping("cartVoList")
    public List<CartVo> cartVoList() {
        return cartItemService.cartVoList();
    }
}
